import Vue from 'vue'
import VueRouter from 'vue-router'
// import store from '@/store'
Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    // 登录
    {
      path: '/login',
      component: () => import('@/views/LoginPage')
    },
    // 用户栏
    {
      path: '/',
      component: () => import('@/views/MainLayout'),
      redirect: '/home',
      children: [
        // 主页
        {
          path: 'home',
          component: () => import('@/views/HomePage')
        },
        // 运营工单
        {
          path: '/task/business',
          component: () => import('@/views/task/TaskBusiness')
        },
        // 运维工单
        {
          path: '/task/peration',
          component: () => import('@/views/task/TaskPeration')
        },
        // 人效统计
        {
          path: '/user/user-task-stats',
          component: () => import('@/views/user/UserTaskStats')
        },
        // 工作量列表
        {
          path: '/user/user-work',
          component: () => import('@/views/user/UserWork')
        },
        // 人员列表
        {
          path: '/user/index',
          component: () => import('@/views/user/UserIndex')
        },
        {
          path: '/sku/sku-class',
          component: () => import('@/views/sku/skuClass')
        },
        {
          path: '/sku/sku',
          component: () => import('@/views/sku/skuList')
        },
        // 区域管理
        {
          path: '/node/region',
          component: () => import('@/views/node/RegionManage')
        },
        {
          path: '/vm/index',
          component: () => import('@/views/vm/EquipmentIManager')
        },
        {
          path: '/vm/status',
          component: () => import('@/views/vm/EquipmentStatus')
        },
        {
          path: '/vm/type',
          component: () => import('@/views/vm/EquipmentType')
        }
      ]
    }
  ]
})

// 设置白名单
// const whiteList = ['/login']

// // 设置路由守卫
// router.beforeEach((to, from, next) => {
//   // 如果有 Token
//   if (store.state.user.token) {
//     // 如果去 /login 就转到 /
//     if (to.path === '/login') {
//       next('/')
//     } else {
//       next()
//     }
//   } else {
//     // 如果在白名单就放行
//     if (whiteList.includes(to.path)) {
//       next()
//     } else {
//       next('/login')
//     }
//   }
// })
export default router
